package Computer_Builder_04.Director;
import Computer_Builder_04.AbstractBuilder.ComputerBuilder;
import Computer_Builder_04.Builder.DesktopBuilder;
import Computer_Builder_04.Builder.LaptopBuilder;
import Computer_Builder_04.Builder.ServerBuilder;
import Computer_Builder_04.Product.Product;

public class Director {
    public Product constructComputer(String computerType) {
        ComputerBuilder computerBuilder;
        switch (computerType) {
            case "Laptop":
                computerBuilder = new LaptopBuilder();
                break;
            case "Desktop":
                computerBuilder = new DesktopBuilder();
                break;
            case "Server":
                computerBuilder = new ServerBuilder();
                break;
            default:
                throw new IllegalArgumentException("不支持的电脑类型: " + computerType);
        }
        computerBuilder.buildCPU();
        computerBuilder.buildRAM();
        computerBuilder.buildHDD();
        computerBuilder.buildMonitor();
        computerBuilder.buildHost();
        return computerBuilder.getComputer();
    }
}